package byggeTegning.husGeometri;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

import javax.media.j3d.Group;
import javax.vecmath.Color3f;

import byggeTegning.geometry.Point3D;
import byggeTegning.geometry.TransformedGroup3D;
//import com.sun.j3d.utils.geometry.Cylinder;


// ***************************************************************************
// *** CLASS: TakStokk
// ***************************************************************************
public class TakStokk extends Block
{ 
  public TakStokk(String ident,Point3D p0,double width,double height,double depth)
  { super(ident,p0,width,height,depth); }

  public /*abstract*/ Group getModel3D(Color3f c)  // Using Timber
  {
//    Timber stokk=new Timber(new TimberDimension(0.30,0.30,0.70));
    Timber stokk=new Timber(new TimberDimension(depth,height,0.0));
    double length=width;
    boolean directionNorthSouth=false;
    float topCut=0;
    float botCut=0;
//    TransformedGroup3D tg=stokk.getModel3D(c,p0.x,p0.y,p0.z,length,directionNorthSouth,topCut,botCut);
    TransformedGroup3D tg=stokk.getModel3D(c,p0.x,p0.y,p0.z+depth,length,directionNorthSouth,topCut,botCut);
    return(tg);
  }
  

  public void drawProjection(int direction,Graphics2D g,Point2D.Double origo2D,double scale,Color c)
  { Rectangle2D.Double r=projection(direction,origo2D,scale);
    switch(direction)
    {
//      case NORTH: drawVerticalCut(g,r,scale,c); break;
//      case SOUTH: drawVerticalCut(g,r,scale,c); break;
      case EAST: drawVerticalCut(g,r,scale,c); break;
      case WEST: drawVerticalCut(g,r,scale,c); break;
//      case EAST: drawProjectionEast(g,r,scale,c); break;
//      case WEST: drawProjectionWest(g,r,scale,c); break;
//      case ABOVE: drawProjectionAbove(g,r,scale,c); break;
//      case BELOW: drawProjectionBelow(g,r,scale,c); break;
      case VCUT: drawVerticalCut(g,r,scale,c); break;
//      case HCUT: drawHorisontalCut(g,r,scale,c);
//                 drawExtraProjection(HCUT,g,origo2D,scale,c);
//                 break;
      default: super.drawProjection(direction,g,origo2D,scale,c);
    }  
  }
    
  private void drawVerticalCut(Graphics2D g,Rectangle2D.Double r,double scale,Color c)
  { fillOval(g,r.x,r.y,r.width,r.height,c);
    drawOval(g,r.x,r.y,r.width,r.height);
  }

}  
